package com.c.ctgproject.adapter.guang

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.CheckBox
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.c.ctgproject.R
import com.c.ctgproject.base.BaseEmptyRecyclerViewAdapter
import com.c.ctgproject.base.BaseEmptyRecyclerViewAdapterV2
import com.c.ctgproject.entity.guang.CarCanHandlerEntity
import com.c.ctgproject.utils.handlerNull

class CarCanHandlerSelectAdapter(private val context: Context, private val mList: List<CarCanHandlerEntity.DataBean.ListBean>) : BaseEmptyRecyclerViewAdapterV2(context, mList) {
    override fun createViewHolder(parent: ViewGroup): RecyclerView.ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.item_car_can_handler_select_list, parent, false)
        return MyViewHolder(view)
    }

    override fun handlerData(holder: RecyclerView.ViewHolder, position: Int) {
        if (holder is MyViewHolder) {
            val data = mList[position]
            val type = when (data.carType) {
                1 -> "社会车"
                2 -> "试验车"
                3 -> "外包车"
                4 -> "五类车"
                5 -> "农机具"
                else -> ""
            }
            holder.mCarType.text = type
            holder.mUserNameTV.text = data.createPersonName.handlerNull()
            holder.mVIN.text = data.carVin.handlerNull()
            holder.mTimeTV.text = data.createTime.handlerNull()
            if (position == mList.size - 1) {
                holder.mLine.visibility = View.GONE
            } else {
                holder.mLine.visibility = View.VISIBLE
            }
        }
    }

    inner class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        val mUserNameTV: TextView = view.findViewById(R.id.mUserNameTV)
        val mTimeTV: TextView = view.findViewById(R.id.mTimeTV)
        val mVIN: TextView = view.findViewById(R.id.mVIN)
        val mCarType: TextView = view.findViewById(R.id.mCarType)
        val mLine: View = view.findViewById(R.id.mLine)
    }


}